﻿#region Header

/*
Remote views based on linq
By

Pascal Hauser 
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

and

Raphael Gfeller
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

*/

#endregion

#region Usings

using InterLinq.Test.UI;
using Microsoft.Win32;
using Sebarf.Diagnostics.Interfaces;

#endregion

namespace InterLinq.Test.PD {
	/// <summary>
	/// Description of the class
	/// </summary>
	public class ConnectionStringFactory {
		#region Public Methods

		public static string CreateConnectionString(string testName) {
			string subKey = "Software\\InterLinq\\Tests";
			Registry.CurrentUser.CreateSubKey(subKey);
			var connectionString = (string)Registry.CurrentUser.OpenSubKey(subKey).GetValue(testName, string.Empty);
			if (string.IsNullOrEmpty(connectionString)) {
				new SelectConnectionStringWindow(testName, "HKEY_CURRENT_USER\\" + subKey, testName).ShowDialog();
			}
			connectionString = (string)Registry.CurrentUser.OpenSubKey(subKey).GetValue(testName, string.Empty);

			Check.AssertException(!string.IsNullOrEmpty(connectionString), "unknown connectionString, could not continue");

			return connectionString;
		}

		#endregion
	}
}